package com.cn.kehong.controller;


import com.cn.kehong.api.IPlanYearDynamicService;
import com.cn.kehong.domain.PlanYearDynamic;
import com.cn.kehong.utils.CommonUtil;
import com.cn.kehong.utils.JsonResponse;
import com.cn.kehong.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/PlanYearDynamic")
public class PlanYearDynamicController {

    @Autowired
    private IPlanYearDynamicService planYearDynamicService;

    @RequestMapping("/getPlanYearDynamics/{frontToken}")
    @ResponseBody
    public JsonResponse<List<PlanYearDynamic>> getPlanYearDynamics(String planYear, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<List<PlanYearDynamic>> response = new JsonResponse<List<PlanYearDynamic>>();
        List<PlanYearDynamic> list  = planYearDynamicService.getPlanYearDynamics(planYear);
        response.setResult(list);
        response.setSuccess(true);
        return  response;
    }


    @ResponseBody
    @RequestMapping("/updateBatchPlanYearDynamics/{frontToken}")
    public JsonResponse<String> updateBatchPlanYearDynamics(@RequestBody List<PlanYearDynamic> planYearDynamics, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception {
        JsonResponse<String> response = new JsonResponse<String>();
        String result = planYearDynamicService.updateBatchPlanYearDynamics(planYearDynamics);
        return CommonUtil.getResponseData(response,result);
    }


}
